#ifndef	__CXX_VIEWS_WIDGET_FORMWIN31_H__
#define	__CXX_VIEWS_WIDGET_FORMWIN31_H__

#include "grph/font.h"
#include "widget.h"
#include "formclient.h"

namespace visgrph {
	class canvas;
};

namespace viswidgets
{

class form_win31_impl : public widget
{
	enable_event_handling();
public:
	form_win31_impl(view_t* vi = NULL);
	form_win31_impl(const visgrph::canvas&);
	form_win31_impl(int left, int top, int width, int height, view_t* vi = NULL);
	~form_win31_impl();

	void canvas(const visgrph::canvas& c) {
		m_canvas = c;
	}

	visgrph::canvas* canvas(void) {
		return &m_canvas;
	}

	view_t* client_view(void) {
		return (m_client) ? m_client->getview() : NULL;
	}

public:
	// set the caption of the form
	void caption(const char *cap);

public:
	void on_draw(drawing_context& dc);

// event handlers
private:
	void resize_event_handler(resize_event& ev);

// drawing
private:
	void draw_ctrl_box(visgrph::canvas& cvs);
	void draw_title_bar(visgrph::canvas& cvs, view_t* vi);
	uint get_title_bar_width(uint form_width);

private:
	void create_client(void);
	void init_caption_format(void);

private:
	visgrph::canvas m_canvas;
	visgrph::formatted_text m_caption;
	form_client* m_client;
};

}; // namespace viswidgets
#endif	// __CXX_VIEWS_WIDGET_FORMWIN31_H__
/* EOF */

